package com.zmx.doctor.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;
import com.zmx.doctor.R;
import com.zmx.doctor.view.activity.AboutUsActivity;
import com.zmx.doctor.view.activity.ArticleCollectsActivity;
import com.zmx.doctor.view.activity.CircleOfFriendsActivity;
import com.zmx.doctor.view.activity.CommunityHospitalActivity;
import com.zmx.doctor.view.activity.DoctorCertifiedActivity;
import com.zmx.doctor.view.activity.FeedbackActivity;
import com.zmx.doctor.view.activity.LoginActivity;
import com.zmx.doctor.view.activity.MessageActivity;
import com.zmx.doctor.view.activity.MyBalanceActivity;
import com.zmx.doctor.view.activity.MyClinicActivity;
import com.zmx.doctor.view.activity.PersonalDataActivity;
import com.zmx.doctor.view.activity.SetUpActivity;
import com.zmx.doctor.view.util.CustomToast;
import com.zmx.doctor.view.util.MySharedPreferences;

import de.hdodenhof.circleimageview.CircleImageView;

public class FourFragment extends Fragment {

    private TextView phone,my_balance,store_message,my_message,members_name,community_hospital,article_collects,feedback,about,out,doctor_certified,doctor_clinic;

    private CircleImageView image_head;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_four, container, false);

        image_head = view.findViewById(R.id.image_head);
        phone = view.findViewById(R.id.phone);
        members_name = view.findViewById(R.id.members_name);
        members_name.setText(MySharedPreferences.getInstance(this.getActivity()).getString(MySharedPreferences.name, ""));
        phone.setText(MySharedPreferences.getInstance(this.getActivity()).getString(MySharedPreferences.mobile, ""));
        Glide.with(getActivity()).load(MySharedPreferences.getInstance(this.getActivity()).getString(MySharedPreferences.avatar, "")).into(image_head);

        doctor_certified = view.findViewById(R.id.doctor_certified);
        doctor_certified.setOnClickListener(v -> {

            Intent intent = new Intent();
            intent.setClass(FourFragment.this.getContext(), DoctorCertifiedActivity.class);
            startActivity(intent);

        });
        my_balance = view.findViewById(R.id.my_balance);
        my_balance.setOnClickListener(v -> {

            Intent intent = new Intent();
            intent.setClass(FourFragment.this.getContext(), MyBalanceActivity.class);
            startActivity(intent);

        });
        doctor_clinic = view.findViewById(R.id.doctor_clinic);
        doctor_clinic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent();
                intent.setClass(FourFragment.this.getContext(), MyClinicActivity.class);
                startActivity(intent);

            }
        });

        store_message = view.findViewById(R.id.store_message);
        store_message.setOnClickListener(v -> {
            Intent intent = new Intent();
            intent.setClass(FourFragment.this.getContext(), PersonalDataActivity.class);
            startActivity(intent);
        });

        out = view.findViewById(R.id.out);
        out.setOnClickListener(v -> {

            MySharedPreferences.getInstance(this.getActivity()).clear();//清空本地数据
            Intent intent = new Intent();
            intent.setClass(this.getActivity(), LoginActivity.class);
            startActivity(intent);
            this.getActivity().finish();

        });

        my_message = view.findViewById(R.id.my_message);
        my_message.setOnClickListener(v -> {
            Intent intent = new Intent();
            intent.setClass(FourFragment.this.getContext(), MessageActivity.class);
            startActivity(intent);
        });

        community_hospital = view.findViewById(R.id.community_hospital);
        community_hospital.setOnClickListener(v -> {
            Intent intent = new Intent();
            intent.setClass(FourFragment.this.getContext(), CircleOfFriendsActivity.class);
            startActivity(intent);
        });

        article_collects = view.findViewById(R.id.article_collects);
        article_collects.setOnClickListener(v -> {
            Intent intent = new Intent();
            intent.setClass(FourFragment.this.getContext(), ArticleCollectsActivity.class);
            startActivity(intent);
        });
        feedback = view.findViewById(R.id.feedback);
        feedback.setOnClickListener(v -> {
            Intent intent = new Intent();
            intent.setClass(FourFragment.this.getContext(), FeedbackActivity.class);
            startActivity(intent);
        });
        about = view.findViewById(R.id.about);
        about.setOnClickListener(v -> {
            Intent intent = new Intent();
            intent.setClass(FourFragment.this.getContext(), SetUpActivity.class);
            startActivity(intent);
        });
        return view;
    }


}